<!DOCTYPE html>
<html>
<head>
	<title>购物车</title>
	<link rel="stylesheet" type="text/css" href="/bower_components/bootstrap/dist/css/bootstrap.min.css">
	<link rel="stylesheet" type="text/css" href="/styles/member.css">
	<link rel="stylesheet" type="text/css" href="/styles/main.css">
	<script type="text/javascript" src="/bower_components/jquery/dist/jquery.min.js"></script>
	<script type="text/javascript" src="/bower_components/bootstrap/dist/js/bootstrap.min.js"></script>
</head>
<body>
	<% include top.ejs %>
	<div class="container">
		<div class="col-xs-8">
			<div id="main_right">
				<p class="welcome">购物车详情<a href="/" class="pull-right">返回首页>></a></p>
				<input class="inp" type="checkbox" name="all" onclick="checkAll()" />全选<br /> 
				<% if(buy.length!=0){for(i=0;i<buy.length;i++){%>
				<input class="inp" type="checkbox" name="item" value="<%=buy[i].price%>" /><%=buy[i].abstract%>：<%=buy[i].price%>元<a href="/delshopping?id=<%=buy[i].id%>" class="pull-right shopping_car">删除</a><br/>
				<%}%>
				<%}%>
				<br>
				<br>
				<a href="/del_all_shopping" class="pull-right shopping_car">清空购物车</a><br><br>
				<input class="inp btn btn-success pull-right" type="button" value="结算" onclick="getSum()" />

				<span class="inp" id="sum"></span> 
			</div>
		</div>
	</div>
	<br/>
	<br/>
	<br/>
	<% include footer.ejs %>
</body>
</html>
<script type="text/javascript">
	function checkAll() 
{ 
//var allNode = document.getElementsByName("all")[0]; 
//获取被点击的元素 
var allNode = event.srcElement; 
var item = document.getElementsByName("item"); 
for(var x=0;x<item.length;x++) 
{ 
item[x].checked = allNode.checked; 
} 
} 


function getSum() 
{ 
var item = document.getElementsByName("item"); 
var sum = 0; 
for(var x=0;x<item.length;x++) 
{ 
if(item[x].checked) 
{ 
sum+=parseInt(item[x].value); 
} 
} 
var spanNode = document.getElementById("sum"); 
spanNode.innerHTML = (sum+"元").fontsize(7); 
} 

</script>